package actionForm;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginValidationForm extends ActionForm{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String name = null;
	private String password = null;
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public ActionErrors validate(
			ActionMapping mapping, HttpServletRequest request ) {
		ActionErrors errors = new ActionErrors();
		if( getName()== null || getName().length() < 1 ) {
			errors.add("name",new
					ActionMessage("creation.username.error.required"));
		}
		if( getPassword()== null || getPassword().length() < 1 ) {
			errors.add("last name",new
					ActionMessage("creation.password.error.required"));
		}
		return errors;
	}
	
}
